﻿CREATE VIEW dbo.VIEW_PAY_IN_ON_INV_OUT
AS
SELECT        dbo.PAYMENT_IN.NUMBER AS PAYMENT_IN_NUMBER, dbo.PAY_IN_ON_INV_OUT.ID, dbo.PAY_IN_ON_INV_OUT.PAYMENT_IN_ID, 
                         dbo.PAY_IN_ON_INV_OUT.INVOICE_OUT_ID, dbo.PAY_IN_ON_INV_OUT.SUM_CUR, dbo.PAY_IN_ON_INV_OUT.SUM_RUB, dbo.PAY_IN_ON_INV_OUT.PID, 
                         dbo.PAYMENT_IN.DATE AS PAYMENT_IN_DATE, dbo.NSI_CURRENCY.SHORT_NAME AS NSI_CURRENCY_NAME, 
                         dbo.INVOICE_OUT.NUMBER AS INVOICE_OUT_NUM
FROM            dbo.PAY_IN_ON_INV_OUT INNER JOIN
                         dbo.PAYMENT_IN ON dbo.PAY_IN_ON_INV_OUT.PAYMENT_IN_ID = dbo.PAYMENT_IN.ID INNER JOIN
                         dbo.INVOICE_OUT ON dbo.PAY_IN_ON_INV_OUT.INVOICE_OUT_ID = dbo.INVOICE_OUT.ID INNER JOIN
                         dbo.NSI_CURRENCY ON dbo.INVOICE_OUT.NSI_CURRENCY_ID = dbo.NSI_CURRENCY.ID